package com.hmall.order.config;

import com.hmall.order.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    /**
     * 添加外部拦截器，需要重写WebMvcConfiguration中的addInterceptors方法，
     * 在InterceptorRegistry中添加自己创建的拦截器对象，
     * 设置拦截路径
     * 设置非拦截路径
     * */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor());
        registration.addPathPatterns("/**");
/*        registration.excludePathPatterns("/employee/login",
                "/employee/logout",
                "/backend/**",
                "/front/**");*/
    }
}
